package com.mario;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
import org.apache.poi.ss.usermodel.Workbook;
import org.junit.Test;

import com.mario.excleRead.PhoneInfo;
import com.whty.mariotools.excle.ExcelImport;
import com.whty.system.domain.DepotHeadItem;





public class ExcleImp {
	
//	
////	@Test
////	public void getExcleInfo(){
////		
////		File filePath =new File("D:\\profile\\UID.xls");
////							
////		List<Object> list = ExcelImportUtil.importExcel(TagItem.class, filePath);
////		if(list!=null&&list.size()>0){
////			System.out.println("获取信息");
////		}
////	}
////	
////	@Test
////	public void testimport() throws Exception{
////		File filePath =new File("D:\\profile\\UID.xls");
////		InputStream in = new FileInputStream(filePath);
////		
////		
////		 Map<Integer, Map<Integer,Object>> map=ExcelUtilExcle.readExcelContent(in);
////		 System.out.println("获取信息");
////	
////	}
//	
//	@Test
//	public void testtt() throws InvalidFormatException, IOException, Exception, IllegalAccessException {
//		File filePath =new File("F:\\07-xmic2018\\09-普洱\\UID.xls");
//		ExcelImport ei = new ExcelImport(filePath, 1, 0);
//		List<DepotHeadItem> list = ei.getDataList(DepotHeadItem.class);
//		if(list!=null&&list.size()>0){
//			System.out.println("获取信息");
//			int i=0;
//			for(DepotHeadItem tagItem:list){
//				i=i+1;
//				System.out.println("序号："+i+";uuid:"+tagItem.getUid());
//				System.out.println("序号："+i+";序列号:"+tagItem.getLabelSerialNumber());
//			}
//		}
//	
//	}
	
	@Test
	public void testtt() throws InvalidFormatException, IOException, Exception, IllegalAccessException {
		File filePath =new File("D:\\test-qil.xls");
		ExcelImport ei = new ExcelImport(filePath, 1, 0);
		List<PhoneInfo> list = ei.getDataList(PhoneInfo.class);
		if(list!=null&&list.size()>0){
			System.out.println("获取信息");
			int i=0;
			StringBuilder  sb = new StringBuilder();
			for(PhoneInfo phoneInfo:list){
				i=i+1;
//				System.out.print("{");
//				System.out.print("\"brand\":"+"\""+phoneInfo.getBrand()+phoneInfo.getDetailName()+"\"");
//				System.out.print(",\"model\":"+"\""+phoneInfo.getModel()+"\"");
//				System.out.print(",\"version\":"+"\""+phoneInfo.getVersion()+"\"");
//				System.out.println("},");
				sb.append("{");
				sb.append("\"brand\":"+"\""+phoneInfo.getBrand()+phoneInfo.getDetailName()+"\"");
				sb.append(",\"model\":"+"\""+phoneInfo.getModel()+"\"");
				sb.append(",\"version\":"+"\""+phoneInfo.getVersion()+"\"");
				sb.append("},"+" \r\n");
				
			}
			
			
			System.out.println(sb.toString());
//			writeContent(sb.toString());
			System.out.println("******************写入信息完成************************");
		}
	
	}
	
	public void writeContent(String contentStr) throws Exception{
		
		File file =new File("D:\\test-qil.txt");
		FileOutputStream fileOutputStream = null;
		if(file.exists()){
			file.delete();
		}
		file.createNewFile();
		fileOutputStream = new FileOutputStream(file);
	    fileOutputStream.write(contentStr.getBytes("gbk"));
	        fileOutputStream.flush();
	        fileOutputStream.close();

		
	}


}
